package com.shiyi.design.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangzhanshuai
 * @date 2021/2/2 5:07 下午
 * @since 1.0
 */
public class BranchNode extends Node {

    private List<Node> nodeList = new ArrayList<>();

    public BranchNode(String nodeName) {
        super(nodeName);
    }

    @Override
    public void print() {
        System.out.println(super.nodeName);
    }

    @Override
    public boolean isLeaf() {
        return false;
    }

    public synchronized void addNode(Node node) {
        if (node != null) {
            nodeList.add(node);
        }
    }

    public List<Node> getNodeList() {
        return nodeList;
    }
}
